package com.example.picturegame;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class ShowActivity extends AppCompatActivity {
    private Toolbar toolbar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show);
//        Intent intent = getIntent();
        toolbar = findViewById(R.id.toolbar);
        toolbar.setTitle("拼图游戏");
        setSupportActionBar(toolbar);

//        int timeNum = intent.getIntExtra("time",10);
//        String sqlInsert = "insert into rank time values"+timeNum+";";
        DatabaseHelper helper = new DatabaseHelper(this,"pic.db",null,1);
        SQLiteDatabase db = helper.getReadableDatabase();
//        db.execSQL(sqlInsert);
        String sql = "select time from rank order by time DESC";
        Cursor cursor = db.rawQuery(sql,null);
        cursor.moveToFirst();
        TextView show_view = findViewById(R.id.show_rank);
        int n=0;
        while(!cursor.isAfterLast()) {

            int b = cursor.getInt(cursor.getColumnIndex("time"));
            Log.i("xx", ""+b);
            ++n;
            show_view.append("第"+n+"名       "+"       剩余时间"+b+"秒 \n");
            cursor.moveToNext();
        }
    }
}